<!DOCTYPE html>
<html lang="en">
<head>
    <title>怪兽营</title>
    <meta charset="UTF-8"/>
    <meta name="author" content="zqtao|怪兽营">
    <meta name="email" content="zqtao23@163.com">
    <meta name="keywords" content="囧么肥事,怪兽营,怪兽,机器学习,python,Monster,Ubuntu20.04, Ubuntu20.04安装MongoDB"/>
    <meta name="description" content="怪兽营,快乐的咆哮怪兽, Ubuntu20.04安装MongoDB"/>
    <meta name="viewport"
          content="width=device-width,height=device-height,initial-scale=1.0,maximum-scale=1.0,user-scalable=0"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta http-equiv="Content-Type" content="text/html;"/>
    <meta name="renderer" content="webkit">
    <!--解决页面加载网络图片的403问题 , 可以让img标签预加载网络图片-->
    <meta name="referrer" content="no-referrer" />

    <!--markdown S -->
    <link rel="stylesheet" type="text/css" href="../../static/css/export_setting_css.css"/>
    <link rel="stylesheet" type="text/css" href="../../static/css/markdown_preview_css.css"/>
    <!--markdown E -->

    <!--left bar tools css E-->
    <link rel="stylesheet" type="text/css" href="../../static/css/nav.css">
    <link rel="stylesheet" type="text/css" href="http://www.jq22.com/jquery/font-awesome.4.6.0.css">
    <!--left bar tools css E-->

    <!-- 滚动条 S -->
    <link rel="stylesheet" href="../../static/css/optiscroll.css">
    <!-- 滚动条 E -->
</head>
<body>
<div id="m-wrapper" class="m-wrapper optiscroll">
    <!-- top 锚点 -->
    <a id="top"></a>

    <!-- left bar tools S -->
    <div class="leftNav-item">
        <ul>
            <li>
                <i class="fa fa-location-arrow"></i>
                <a href="http://jiongmefeishi.gitee.io/monster-blog/" target="_blank" class="rota">个人网站</a>
            </li>

            <li title="Git">
                <i class="fa fa-code-fork" aria-hidden="true"></i>
                <a href="http://jiongmefeishi.gitee.io/monster-blog/" target="_blank" class="rota">Git Page</a>
            </li>

            <li lay-data="img" data-fooc="http://resource.zqtaotao.cn/wx/qrcode/jiongmefeishi.jpg">
                <i class="fa fa-comments-o"></i><a href="javascript:;" class="rota">公众号</a>
            </li>

            <li lay-data="img" data-fooc="http://resource.zqtaotao.cn/weixincode.png">
                <i class="fa fa-money"></i><a href="javascript:;" class="rota">小额打赏</a>
            </li>

            <li title="返回顶部" class="for-top">
                <i class="fa fa-arrow-up"></i>
                <a href="#top" class="rota">去顶部</a>
            </li>
        </ul>
    </div>
    <!-- left bar tools E -->



    <!--content S-->

    <div id="export_content"><div class="output_wrapper" id="output_wrapper_id"><h3 id="hubuntu2004mongodb"><span>Ubuntu20.04 安装MongoDB</span></h3>
        <p>源码安装 <a href="https://www.mongodb.com/download-center#community">MongoDB官网地址</a></p>
        <pre><code class="hljs nginx"><span class="hljs-attribute">MongoDB</span>&nbsp;源码下载地址：https://www.mongodb.com/download-center#community<br></code></pre>
        <p>选择Ubuntu对应版本，类似菜鸟教程截图如下</p>
        <figure><img src="https://upload-images.jianshu.io/upload_images/18567339-37803042969f606a.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="选择版本" title="选择版本"><figcaption>选择版本</figcaption></figure>
        <p>本系统Ubuntu20.04, 下载对应版本</p>
        <pre><code class="hljs nginx"><span class="hljs-attribute">wget</span>&nbsp;https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-ubuntu2004-4.4.1.tgz<br></code></pre>
        <p>解压安装</p>
        <pre><code class="hljs coffeescript">tar&nbsp;-zxvf&nbsp;mongodb-linux-x86_64-ubuntu2004<span class="hljs-number">-4.4</span><span class="hljs-number">.1</span>.tgz&nbsp;~<span class="hljs-regexp">/app/</span><br></code></pre>
        <p>MongoDB 的可执行文件位于 bin 目录下，所以可以将其添加到 <strong>PATH</strong> 路径中：</p>
        <pre><code class="hljs nginx"><span class="hljs-attribute">vim</span>&nbsp;~/.bashrc<br></code></pre>
        <p>添加执行路径</p>
        <pre><code class="hljs ruby">export&nbsp;PATH=<span class="hljs-regexp">/home/learn</span><span class="hljs-regexp">/app/mongodb</span>-linux-x86_64-ubuntu2004-<span class="hljs-number">4.4</span>.<span class="hljs-number">1</span>/<span class="hljs-symbol">bin:</span>$PATH<br></code></pre>
        <p>激活配置文件</p>
        <pre><code class="hljs bash"><span class="hljs-built_in">source</span>&nbsp;~/.bashrc<br></code></pre>
        <h2 id="h"><span>创建数据库目录</span></h2>
        <p>默认情况下 MongoDB 启动后会初始化以下两个目录：</p>
        <ul>
            <li><span>数据存储目录：/var/lib/mongodb</span></li>
            <li><span>日志文件目录：/var/log/mongodb</span></li>
        </ul>
        <p>我们在启动前可以先创建这两个目录并设置当前用户有读写权限：</p>
        <pre><code class="hljs perl">sudo&nbsp;<span class="hljs-keyword">mkdir</span>&nbsp;-p&nbsp;/var/lib/mongo<br>sudo&nbsp;<span class="hljs-keyword">mkdir</span>&nbsp;-p&nbsp;/var/<span class="hljs-keyword">log</span>/mongodb<br>sudo&nbsp;<span class="hljs-keyword">chown</span>&nbsp;<span class="hljs-string">`whoami`</span>&nbsp;/var/lib/mongo&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="hljs-comment">#&nbsp;设置权限</span><br>sudo&nbsp;<span class="hljs-keyword">chown</span>&nbsp;<span class="hljs-string">`whoami`</span>&nbsp;/var/<span class="hljs-keyword">log</span>/mongodb&nbsp;&nbsp;&nbsp;<span class="hljs-comment">#&nbsp;设置权限</span><br></code></pre>
        <p>接下来启动 Mongodb 服务：</p>
        <pre><code class="hljs cpp">mongod&nbsp;--dbpath&nbsp;/var/lib/mongo&nbsp;--logpath&nbsp;/var/<span class="hljs-built_in">log</span>/mongodb/mongod.<span class="hljs-built_in">log</span>&nbsp;--fork<br></code></pre>
        <p>更多内容,如window 安装MongoDB，参考：<br><a href="https://www.runoob.com/mongodb/mongodb-window-install.html">菜鸟教程</a></p></div></div>

    <!--content E-->
</div>



</body>
<!--left bar tools js S-->
<script src="http://www.jq22.com/jquery/jquery-1.10.2.js"></script>
<script type="text/javascript" src="../../static/js/nav.js"></script>
<!--left bar tools js E-->

<!-- 滚动条 S -->
<script type="text/javascript" src="../../static/js/optiscroll.js"></script>
<!-- 滚动条 E -->

<!--commonjs S-->
<script type="text/javascript" src="../../static/js/common.js"></script>
<!--commonjs E-->

</html>
